package com.foolishbird.sdk.ui.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.foolishbird.sdk.ui.assist.OnFinishActivityListener;


public class CertifiesTipDialogFragment extends BaseDialogFragment implements View.OnClickListener {


    private Button mConfirmEvent;
    private TextView mMessageContent;

    public static final CertifiesTipDialogFragment newInstance(Bundle bundle) {
        CertifiesTipDialogFragment fragment = new CertifiesTipDialogFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View contentView = doInflateContentView(inflater, container, getLayoutIdentifier("hnssn_fragment_certifies_tip"));

        mMessageContent = contentView.findViewById(getViewIdentifier("fragment_certifies_tip_message"));
        mConfirmEvent = contentView.findViewById(getViewIdentifier("fragment_certifies_tip_confirm"));
        mConfirmEvent.setOnClickListener(this);

        Bundle bundle = getArguments();
        if (bundle != null && bundle.containsKey("goods")) {
            mMessageContent.setText(getStringIdentifier("hnssn_certifies_tip_message"));
        } else {
            mMessageContent.setText(getStringIdentifier("hnssn_certifies_tip_guest_message"));
        }

        return contentView;
    }

    @Override
    public void onClick(View view) {
        OnFinishActivityListener listener = getOnFinishActivityListener();
        if (listener != null) {
            listener.doFinishActivity(this);
        }
    }

    private OnFinishActivityListener getOnFinishActivityListener() {
        if (!isNullContext()) {
            Activity activity = getActivity();
            if (activity instanceof OnFinishActivityListener) {
                return (OnFinishActivityListener) activity;
            }
        }
        return null;
    }
}
